<script>
	import {
		mapMutations
	} from 'vuex'
	export default {
		globalData: {
		isNav:false,//是否已经跳转，在每个页面的onShow中设置为false，每次跳转之后设置为true，每次跳转都进行判断，如果为true，那么就不进行跳转
		screenHeight: 0, //整个屏幕高度 px
		statusHeight: 0, //状态栏高度 px
		winHeight: 0, //可用屏幕高度 px,不包括顶部标题栏
		winWidth: 0, //屏幕宽度 px
		ratio: 0, //px和rpx的比例
		nvaBarHeight: 44, //导航栏高度 px
		tabBarHeight: 50, //tabbar高度 px
		winHeightWithOutTabbar: 0, //带tabbar的可用高度
		  },
		methods: {
			...mapMutations(['login']),
			getHeight() {
			  let that = this;
			  let gd = that.globalData;
			  uni.getSystemInfo({
			    success: function (res) {
				console.log(res);
			      let width = res.windowWidth;
			      let ratio = 750 / width;
			      gd.ratio = ratio;
			      gd.screenHeight = res.screenHeight;
			      gd.statusHeight = res.statusBarHeight;
			      gd.winHeight = res.windowHeight-gd.statusHeight-gd.nvaBarHeight;
			      gd.winWidth = res.windowWidth;
			      gd.winHeightWithOutTabbar =
			      gd.screenHeight - gd.statusHeight - gd.nvaBarHeight;
			      // gd.tabBarHeight = gd.winHeightWithOutTabbar - gd.winHeight;
			    },
			  });
			},
		},
		onLaunch: function() {
			// #ifdef APP-PLUS  
			const _self = this;  
			console.log("push register...");
			const _handlePush = function(message) {  
				/**  
				 * 通过 vuex 来同步页面的数据，仅做演示。  
				 * 实际开发中，这里可能是跳转到某个页面等操作，请根据自身业务需求编写。  
				 * 点击通知后跳转到任务页面
				 */  
				// console.log(message);
				//打开app
				// plus.runtime.openURL( 'hbuilder://',function(res){
				// 	console.log(res);
				// },'cn.puyunwl.mindclass');
				console.log(message.title);
				if(message.title.indexOf("思政作业")!=-1) {
					uni.navigateTo({
						url:'/pages/index/homework/homework',
					})
				} else if(message.title.indexOf("实践任务")!=-1) {
					uni.navigateTo({
						url:'/pages/index/renwu/renwuxue',
					})
				}
				 /*
				uni.navigateTo({
					url:'/pages/index/renwu/renwuxue',
				})
				*/
				_self.updatePushMessage(message);
			};  
			plus.push.addEventListener('click', function(message) {  
				// plus.nativeUI.toast('push click');  
				_handlePush(message);  
			});  
			plus.push.addEventListener('receive', function(message) {  
				// plus.nativeUI.toast('push receive');  
				// _handlePush(message);  
			});  
			// #endif  
			this.getHeight();
			uni.getStorage({
				key: 'uerInfo',
				success: (res) => {
					this.login(res.data);
				},
				fail:(res) =>{
					// console.log(res)
				}
			});
		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	/* 官方ui库 */
	@import "/common/uni.css";
	/* 第三方动画库 */
	@import "/common/animate.min.css";
	/* 自定义图标库 */
	@import "/common/icon.css";
	/* 公共样式 */
	@import "/common/common.css";

	img {
		width: 100% !important;
	}

	body,
	html {
		height: auto;
	}
	.downFile {
		border-radius: 10rpx;
		color: #fff;
		background-color: #FF4351;
		border-color: #FF4351;
		font-weight: 300;
		font-size: 20rpx;
		font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
		text-decoration: none;
		text-align: center;
		line-height: 60rpx;
		height: 60rpx;
		padding: 0 60rpx;
		margin: 0;
		display: inline-block;
		appearance: none;
		cursor: pointer;
		border: none;
		-webkit-box-sizing: border-box;
		-moz-box-sizing: border-box;
		box-sizing: border-box;
		-webkit-transition-property: all;
		transition-property: all;
		-webkit-transition-duration: .3s;
		transition-duration: .3s;
	}
	.style102 {
	  background-image: url(/static/baogao.png);
	  background-repeat: no-repeat;
	  background-size: 100% 100%;
	  width: 100%;
	  height: 100%;
	}
	.style103 {
		font-size: 50rpx;
		font-family: Adobe Heiti Std;
		font-weight: normal;
		color: #cdb260;
		line-height: 80rpx;
	}
	.style101 {
		font-size: 48rpx;
		margin-left: 80rpx;
		color: #fbcd8e;
		line-height: 52rpx;
	}
	.close_btn {
		color: #666;
		background-color: #EEE;
		border-color: #EEE;
		font-weight: 300;
		font-size: 16rpx;
		font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
		text-decoration: none;
		text-align: center;
		line-height: 40rpx;
		height: 40rpx;
		padding: 0 40rpx;
		margin: 0;
		display: inline-block;
		appearance: none;
		cursor: pointer;
		border: none;
		-webkit-box-sizing: border-box;
		-moz-box-sizing: border-box;
		box-sizing: border-box;
		-webkit-transition-property: all;
		transition-property: all;
		-webkit-transition-duration: .3s;
		transition-duration: .3s;
		background-color: #A5DE37;
		border-color: #A5DE37;
		color: #FFF;
		border-radius: 200rpx;
		line-height: 60rpx;
		height: 60rpx;
		padding: 0 60rpx;
		
	}
	.pdfViewBtn {
		color: #666;
		background-color: #EEE;
		border-color: #EEE;
		font-weight: 300;
		font-size: 20rpx;
		font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
		text-decoration: none;
		text-align: center;
		line-height: 40rpx;
		height: 40rpx;
		padding: 0 40rpx;
		margin: 0;
		display: inline-block;
		appearance: none;
		cursor: pointer;
		border: none;
		-webkit-box-sizing: border-box;
		-moz-box-sizing: border-box;
		box-sizing: border-box;
		-webkit-transition-property: all;
		transition-property: all;
		-webkit-transition-duration: .3s;
		transition-duration: .3s;
		background-color: #1B9AF7;
		border-color: #1B9AF7;
		color: #FFF;
		border-radius: 6px;
		margin-right: 10px;
		line-height: 60rpx;
		height: 60rpx;
		padding: 0 60rpx;
		
	}
	.pdf_view {
		width: 100vw;
		position: fixed;
		z-index: 99999;
	}
</style>
